package main

import (
	"encoding/json"
	"fmt"
	"gitee.com/Rankx_code/ego_tools/gen"
)

func main() {

	fmt.Println(0x29)

}

func Gen() {
	var (
		module = "club_cancel_log"
		table  = "auto_test_register"
		//dsn    = "host=192.168.0.9 user=qipai password=qipai#xq5 dbname=clubdb port=5432 sslmode=disable TimeZone=Asia/Shanghai"
		dsn = "host=192.168.0.9 user=qipai password=qipai#xq5 dbname=clubdb port=5432 sslmode=disable TimeZone=Asia/Shanghai"
		//dsn = "host=192.168.0.9 user=qipai password=qipai#xq5 dbname=statdb port=5432 sslmode=disable TimeZone=Asia/Shanghai"
		//dsn = "host=192.168.0.9 user=qipai password=qipai#xq5 dbname=qipaidb port=5432 sslmode=disable TimeZone=Asia/Shanghai"
		//dsn = "host=49.234.137.226 user=zonst_xyx password=zonst_xyx_fengtao dbname=xyxpropapisrv port=5432 sslmode=disable TimeZone=Asia/Shanghai"
		//dsn = "host=49.234.137.226 user=zonst_xyx password=zonst_xyx_fengtao dbname=activitydb port=5432 sslmode=disable TimeZone=Asia/Shanghai"
	)

	gener := gen.NewGener(table, module, dsn, gen.WithModel() /*, gen.WithService(), gen.WithCurd(), gen.WithRedis(), gen.WithApi()*/)
	gener.Generate()
}

func GenMysql() {
	var (
		module = "game_config_v2"
		table  = "game_config_v2"
		dsn    = "developer:zonst!123@(192.168.10.2:3306)/mahpilot_dev?charset=utf8&parseTime=True&loc=Local&readTimeout=10s&timeout=10s&writeTimeout=30s"
	)

	gener := gen.NewGener(table, module, dsn, gen.WithModel(), gen.WithSource(gen.Mysql))
	gener.Generate()
}

// GameExtend 扩展信息
type GameExtend struct {
	JumpCoin  int32 `json:"jump_coin"`  // 跳转金币场
	JumpYueJu int32 `json:"jump_yueju"` // 跳转约局场
}

func GetGameExtend(gameExtend string) GameExtend {
	var (
		extends = GameExtend{JumpCoin: -1, JumpYueJu: -1}
	)
	if gameExtend == "" {
		return extends
	}

	if err := json.Unmarshal([]byte(gameExtend), &extends); err != nil {
		fmt.Println("GameConfigV2.GetGameExtend.Unmarshal error", gameExtend, err.Error())
	}
	return extends
}

type GameExtend1 struct {
	JumpCoin  int32  `json:"jump_coin"`            // 跳转金币场
	JumpYueJu *int32 `json:"jump_yueju,omitempty"` // 跳转约局场
}
